package test.orm;

import static org.junit.Assert.*;

import java.io.IOException;  
import java.sql.Connection;  
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.naming.Context;  
import javax.naming.InitialContext;  
import javax.servlet.ServletException;  
import javax.servlet.http.HttpServlet;  
import javax.servlet.http.HttpServletRequest;  
import javax.servlet.http.HttpServletResponse;  

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import zdy.web.orm.JDBCPool;
//tomcat-jdbc-pool 用例
public class teconn {

	@Before
	public void setUp() throws Exception {
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void test() {	
        Connection con = null;            
        try {  
              
            con = JDBCPool.getConnection();  
            Statement st = con.createStatement();  
            ResultSet rs = st.executeQuery("select * from user");  
            while (rs.next()) {  
                System.out.println(". Host:" + rs.getString(2) + " Password:" + rs.getString(3));  
            }  
            rs.close();  
            st.close();  
              
        } catch (SQLException e) {  
            e.printStackTrace();  
        } finally {  
            if (con != null)  
                try {  
                    con.close();  
                } catch (Exception ignore) {  
            }  
        }  
	}

}
